const useQuery = () => {
  const search = window.location.search.replace(/^\?/g, "");
  const query = search.split("&").reduce((res: any, cur: any) => {
    const [key, value]: [string, string] = cur
      .split("=")
      .map(decodeURIComponent);
    res[key] = value;
    return res;
  }, {});
  return search ? query : {};
};

export default useQuery;
